import request from '@/utils/request'

export function getAutos() {
  return request({
    url: '/autos',
    method: 'get'
  })
}

export function addAuto(form) {
  var data = JSON.parse(JSON.stringify(form))
  data.condition = JSON.stringify(data.condition)
  data.run = JSON.stringify(data.run)
  return request({
    url: '/auto',
    method: 'post',
    data
  })
}

export function getAuto(id) {
  return request({
    url: '/auto/' + id,
    method: 'get'
  })
}

export function deleteAuto(id) {
  return request({
    url: '/auto/' + id,
    method: 'delete'
  })
}

export function editAuto(form) {
  var data = JSON.parse(JSON.stringify(form))
  data.condition = JSON.stringify(data.condition)
  data.run = JSON.stringify(data.run)
  return request({
    url: '/auto',
    method: 'put',
    data
  })
}
